<div class="row">

    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
        <div class="widget am-cf">
            <div class="widget-head am-cf">
                <div class="widget-title am-fl">基础数据添加</div>
                <div class="widget-function am-fr">
                </div>
            </div>
            <div class="widget-body am-fr">

                <form id="formBaseInfo" class="am-form tpl-form-line-form">

                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">字典标签 <span class="tpl-form-line-small-title"></span></label>
                        <div class="am-u-sm-9">
                            <input type="text" class="tpl-form-input" id="label" name="label" placeholder="请输入字典标签">
                            <small>字典标签指这一个分类的标识，比如民族这个分类。</small>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">字典标签英文标识 <span class="tpl-form-line-small-title"></span></label>
                        <div class="am-u-sm-9">
                            <input type="text" class="tpl-form-input" id="labelEn" name="labelEn" placeholder="请输入字典标签英文标识">
                            <small>和字典标签一样，方便数据库的查询，以免浏览器传递后中文乱码问题。</small>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">字典键 <span class="tpl-form-line-small-title">key</span></label>
                        <div class="am-u-sm-9">
                            <input type="text" class="tpl-form-input" id="key" name="key" placeholder="请输入字典键">
                            <small>字典键指该字典标签下的组成部分，比如民族是由汉族、回族、维吾尔、蒙古族等组成的。</small>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">字典值 <span class="tpl-form-line-small-title">value</span></label>
                        <div class="am-u-sm-9">
                            <input type="text" class="tpl-form-input" id="value" name="value" placeholder="请输入字典值">
                            <small>字典值是该键的一些补充信息，比如汉族的人口信息等。</small>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">排序 <span class="tpl-form-line-small-title">Title</span></label>
                        <div class="am-u-sm-9">
                            <input type="text" class="tpl-form-input" id="sorting" name="sorting" placeholder="">
                            <small>排序信息是在该分组的排序等级，值越小，则越排前面。</small>
                        </div>
                    </div>


                    <div class="am-form-group">
                        <div class="am-u-sm-9 am-u-sm-push-3">
                            <button type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " onclick="addBaseInfo()">数据提交</button>
                            <button type="button" class="am-btn am-btn-success " onclick="javascrtpt:window.location.href='/main/indexUrl.php'">返回首页</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>    </div>
</div>


<script type="text/javascript">

    /**
     * 新增基础信息
     */
    function addBaseInfo() {
        var label = $("#label").val();
        var key = $("#key").val();
        if (checkNull(label)) {
            alert("字典标签不能为空");
            return;
        }
        if (checkNull(key)) {
            alert("字典键不能为空");
            return;
        }

        var url = "${request.contextPath}/base/addBaseInfo.php";
        var formBaseInfo = $("#formBaseInfo").serialize();
        $.ajax({
            url: url,
            type:"post",
            dataType:"json",
            data:formBaseInfo,
            success:function(data){
                if (data.status == "success"){
                    alert("添加成功");
                } else if (data.status == 'error'){
                    alert(data.msg);
                } else {
                    alert("未知情况");
                }
            },
            error:function(e){
                alert("错误！！");
            }
        });

    }


</script>